package com.vite.common.config;

import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 读取项目相关配置
 */
@Getter
@Component
@ConfigurationProperties(prefix = "vite")
public class ViteConfig
{

    /** 上传路径 */
    @Getter
    private static String profile;

    /** 获取地址开关 */
    @Getter
    private static boolean addressEnabled;

    /** 是否开启验证码 */
    @Getter
    private static boolean captchaEnable;

    /** 初始密码提示*/
    @Getter
    private static boolean initPasswordEnable;

    /** 验证码类型 */
    @Getter
    private static String captchaType;

    /** 文件最大上次大小 */
    @Getter
    private static long fileMaxSize;

    /** 密码过期天数 */
    @Getter
    private static int passwordExpireDay;


    public void setProfile(String profile)
    {
        ViteConfig.profile = profile;
    }

    public void setAddressEnabled(boolean addressEnabled)
    {
        ViteConfig.addressEnabled = addressEnabled;
    }

    public void setCaptchaEnable(boolean captchaEnable)
    {
        ViteConfig.captchaEnable = captchaEnable;
    }

    public void setInitPasswordEnable(boolean initPasswordEnable) {
        ViteConfig.initPasswordEnable = initPasswordEnable;
    }

    public void setPasswordExpireDay(int passwordExpireDay) {
        ViteConfig.passwordExpireDay = passwordExpireDay;
    }

    public void setCaptchaType(String captchaType) {
        ViteConfig.captchaType = captchaType;
    }

    public void setFileMaxSize(long fileMaxSize) {
        ViteConfig.fileMaxSize = fileMaxSize;
    }

    /**
     * 获取导入上传路径
     */
    public static String getImportPath()
    {
        return getProfile() + "/import";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath()
    {
        return getProfile() + "/download/";
    }

}
